﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Subsonic.ViewModels;
using Subsonic.Data;
using Subsonic.Controls;
using Microsoft.Phone.Shell;
using Subsonic.Resources;

namespace Subsonic.Pages
{
    public partial class PlayQueue : PhoneApplicationPage
    {
        public PlayQueue()
        {
            InitializeComponent();
            DataContext = new MainViewModel();

            _mediaApplicationBar = new MediaApplicationBar(this);
            ApplicationBarIconButton abib = new ApplicationBarIconButton(new Uri("/Images/appbar.delete.rest.png", UriKind.Relative));
            abib.Text = "{player_clear_queue}".StaticResource();
            abib.Click +=new EventHandler(abib_Click);
            _mediaApplicationBar.Page.ApplicationBar.Buttons.Add( abib );
        }

        void abib_Click(object sender, EventArgs e)
        {
            throw new NotImplementedException();
        }

        private MediaApplicationBar _mediaApplicationBar;

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            MainViewModel mvm = (MainViewModel)DataContext;
            foreach (var item in MusicPlayer.Instance.Queue)
            {
                mvm.Items.Add(new QueueItem(item));
            }
        }
    }
}